﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Demo.Test.Times;
using Demo.Test.StackQueue;

namespace Demo.Test.Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void UnSafeTime()
        {
            Int32 delayTime =0;
            Int32 intervalTime =300;
            Int32 runTime=10;
            Int32 runSleep =400;
            UnSafeTimes.Init(delayTime, intervalTime, runTime, runSleep);
            System.Threading.Thread.Sleep(20000);
            Assert.IsTrue(runTime == UnSafeTimes.Count);
        }

        [TestMethod]
        public void SafeTime()
        {
            Int32 delayTime = 0;
            Int32 intervalTime = 300;
            Int32 runTime = 10;
            Int32 runSleep = 400;
            SafeTimes.Init(delayTime, intervalTime, runTime, runSleep);
            System.Threading.Thread.Sleep(20000);
            Assert.IsTrue(runTime == SafeTimes.Count);
        }

        [TestMethod]
        public void StackTest()
        {
            Entity entity1 = new Entity() { Name = "luoliang1", Age = 1 };
            Entity entity2 = new Entity() { Name = "luoliang2", Age = 2 };
            Entity entity3 = new Entity() { Name = "luoliang2", Age = 3 };
            Entity entity4 = new Entity() { Name = "luoliang2", Age = 4 };
            Entity entity5 = new Entity() { Name = "luoliang2", Age = 5 };
            Stack stack = new Stack();
            stack.In(new Node<Entity>(entity1));
            stack.In(new Node<Entity>(entity2));
            stack.In(new Node<Entity>(entity3));
            stack.In(new Node<Entity>(entity4));
            stack.In(new Node<Entity>(entity5));
            var obj = stack.Out();
            var obj1 = stack.Out();
            Assert.AreEqual(entity4, obj1.Data);
        }
    }
}
